const db=require('../db/index')
exports.deletecode=(email)=>{
    var sql = 'delete from vercode where email=?'
    db.query(sql,email,(err,results)=>{
    if(err)   console.log(err)
    if (results.affectedRows !== 1)  console.log("未能删除code记录")
     console.log("删除code记录成功")
})
    
}

exports.insertcode=(code,email,time)=>{
    var sql = 'insert into vercode set ?'
        db.query(sql,{vcode:code,email:email,time:time},(err,results)=>{
        if(err)  console.log(err)
        if (results.affectedRows !== 1)  console.log("未能插入code记录")
         console.log("插入code记录成功")
    })
}

exports.findone=(email,callback)=>{
    var sql='select * from vercode where email=?'
    db.query(sql,email,(err,results)=>{
        if(err)  console.log(err)
        if (results.length !==1)  console.log("未能找到code记录")
         console.log("找到code记录成功")    
         callback(results)
    })
}